<template>
  <div>
    <div style="text-align: right; padding-bottom: 10px;">
      <span style="padding-right: 10px;">{{ $t('m.system.position.other.selected_position') }}：{{position.positionName}}</span>
      <ych-icon type="close-circle" @click="hideUserList"/>
    </div>

    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">
          <a-col :sm="12">
            <a-form-item :label="$t('m.system.position.entity.username')">
              <a-input placeholder="" v-model="queryParam.username"></a-input>
            </a-form-item>
          </a-col>
          <a-col :sm="12">
            <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
              <a-button type="primary" @click="searchQuery" icon="search">{{ $t('m.common.button.query') }}</a-button>
              <a-button type="default" @click="searchReset" icon="reload" style="margin-left: 8px">{{ $t('m.common.button.reset') }}</a-button>
            </span>
          </a-col>
        </a-row>
      </a-form>
    </div>
    <!-- table区域-begin -->
    <a-table
      ref="table"
      bordered
      size="middle"
      rowKey="id"
      :columns="columns"
      :dataSource="dataSource"
      :pagination="ipagination"
      :loading="loading"
      @change="handleTableChange">
    </a-table>
  </div>
</template>
<script>

  import { YcListMixin } from '@/mixins/YcListMixin'
  import { deleteAction, postAction } from '@/api/manage'
  import YchConstant from "@/api/YchConstant";

  export default {
    name: 'SysPositionUserRight',
    mixins: [YcListMixin],
    props: {
      position: Object,
      portal: {
        type: String,
        default: '0'
      }
    },
    data () {
      return {
        queryParam: {
          positionId: this.position.id
        },
        columns: [{
          title: this.$t('m.system.position.entity.username'),
          align: 'center',
          dataIndex: 'username',
          width: 120
        },
          {
            title: this.$t('m.system.position.entity.realname'),
            align: 'center',
            width: 100,
            dataIndex: 'realname'
          },
          {
            title: this.$t('m.system.position.entity.status_dictText'),
            align: 'center',
            width: 80,
            dataIndex: 'status_dictText'
          },
         ],
        url: {
          list: YchConstant.PREFIX_SYSTEM + '/user/userPositionList',
        }
      }
    },
    methods: {
      searchReset () {
        this.queryParam = {
          positionId: this.position.id
        }
        this.loadData(1)
      },
      hideUserList () {
        this.$emit('hideUserList')
      }
    },
    watch: {
      position: {
        handler () {
          this.searchReset()
        },
        immediate: false
      }
    }
  }
</script>
<style lang="less" scoped>

</style>
